<div class="container-fluid">
	<div class="row-fluid">
        <div class="span12">
		<h3 class="page-title"> Usuários <small>Cadastro de usuários</small></h3>
    	<ul class="breadcrumb">
        	<li><a href="#"><i class="icon-home"></i></a><span class="divider">&nbsp;</span></li>
			<li><a href="#">Administra Usuários</a><span class="divider">&nbsp;</span></li>
            <li><a href="#"></a><span class="divider-last">&nbsp;</span></li>
        </ul>
        </div>
    </div>
    <?php
 $nomeEdicao = '';
    if (isset($_GET['id'])) {
        $idEdicao = $_GET['id'];
        $sqlBuscaEdicao = 'SELECT id, nome, email, usuario, senha FROM usuarios';
        $slqBusca = mysql_query($sql);
        $linhaRetornada = mysql_fetch_row($sqlBusca);

        $nomeEdicao = $linhaRetornada['nome'];
        $emailEdicao = $linhaRetornada['email'];
        $usuarioEdicao = $linhaRetornada['usuario'];
        $senhaEdicao = $linhaRetornada['senha'];
        $statusEdicao = $linhaRetornada['status'];

    }

    if(isset($_POST['Salvar'])){
        
        $nome = utf8_encode(addslashes($_POST['nome']));
        $email = addslashes($_POST['email']);
        $usuario = addslashes($_POST['usuario']);
        $senha = addslashes(md5($_POST['senha']));
        $status = addslashes($_POST['status']);

    //$sql = "INSERT INTO `tb_usuario` (`nome_usuario`, `email`, `usuario`, `senha`, `status`, `ultimo_acesso`) VALUES (`".$nome."`, `".$email."`, `".$usuario."`, `".$senha."`, `".$status."`, ".now().");";
    $sqlSalvarUsuario = "INSERT INTO usuarios (nome, email, usuario, senha, ultimo_acesso, status) VALUES ('$nome', '$email', '$usuario', '$senha', NULL, '$status')";
    $sql = mysql_query($sqlSalvarUsuario);
    //mysql_query($sql) or die(mysql_error());
    if ($sql) {
        echo
        '<div class="alert alert-success">
        <button data-dismiss="alert" class="close">×</button>
        <strong>OK!</strong> Usuário salvo com sucesso.</div>';
    }else{
       echo
        '<div class="alert alert-error">
        <button data-dismiss="alert" class="close">×</button>
        <strong>Erro!</strong> Não foi possível salvar o cadastro.</div>';
    }
    }//FIM CADASTRAR
?>
 <div class="row-fluid">
    <div class="span12">
        <div class="widget">
        <div class="widget-title">
            <h4><i class="icon-reorder"></i> Cadastrar Novo Usuário</h4>
            <span class="tools">
                <a href="javascript:;" class="icon-chevron-down"></a>
                <a href="javascript:;" class="icon-remove"></a>
            </span>
        </div>
<div class="widget-body">        
    <form class="form-horizontal" action="gerenciar-usuarios" method="POST">
    <div class="control-group">
        <label class="control-label">Nome</label>
        <div class="controls">
        	<input type="text" name="nome" value="<?php echo $nomeEdicao;?>" class="input-xxlarge" placeholder="Nome Completo"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">E-mail</label>
        <div class="controls">
        	<input type="text" name="email" class="input-xlarge" placeholder="E-mail"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">Usuário</label>
        <div class="controls">
        	<input type="text" name="usuario" class="input-large" placeholder="Usuário de acesso"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">Senha</label>
        <div class="controls">
        	<input type="password" name="senha" class="input-large" placeholder="Senha"/>
        </div>
    </div>
    <label class="control-label">Status</label>
    <div class="controls">
	<label class="radio">
	<div class="radio" id="uniform-undefined">
	<span class="checked">
		<input type="radio" value="ativo" name="status" style="opacity: 0;">
	</span>
	</div>
	Ativo 
	</label>
	<label class="radio">
	<div class="radio" id="uniform-undefined"><span>
	<input type="radio" value="desativado" name="status" style="opacity: 0;">
	</span></div> Desativado 
	</label>
	</div>
    <div class="form-actions">
        <button class="btn btn-success" type="submit" name="Salvar">
        	<i class="icon-ok"></i> Salvar</button>
        <button class="btn btn-warning" type="reset">
        	<i class=" icon-remove"></i> Limpar
        </button>
    </div>
    <input type="hidden" value="salvarUsuario" name="salvar"/>
    </form>
</div>
</div>                   
</div>
</div>
</div>